package com.jn.goods.service.impl;

import com.jn.goods.dao.BrandMapper;
import com.jn.goods.entity.Brand;
import com.jn.goods.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
//实现接口，重写方法
public class BrandServiceImpl implements BrandService {


    @Autowired
    private BrandMapper brandMapper;

    /**
     * 查询所有品牌
     * @return
     */
    @Override
    public List<Brand> findAll() {
        List<Brand> brandList = brandMapper.selectAll();
         return brandList;
    }

    //根据ID查询
    @Override
    public Brand findById(Integer id) {
        return brandMapper.selectByPrimaryKey(id);
    }

    //新增品牌
    @Override
    public void add(Brand brand) {
        brandMapper.insertSelective(brand);
    }

    //修改品牌
    @Override
    public void update(Brand brand) {
        brandMapper.updateByPrimaryKeySelective(brand);
    }

    /*** * 删除品牌 * @param id */
    @Override
    public void delete(Integer id) {
        brandMapper.deleteByPrimaryKey(id);
    }
}
